﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace de.codingfreaks.libs.cfThreadingTools.Extensions
{
    /// <summary>
    /// Provides extensions for <c>System.Windows.Forms.TextBox and subsequent objects.</c>
    /// </summary>
    public static class TextBoxExtensions 
    {

        /// <summary>
        /// Allows thread-safe manipulation of the text-property.
        /// </summary>
        /// <param name="txtTarget">The <c>System.Windows.Forms.TextBox</c>-control.</param>
        /// <param name="strValue">The new text to set.</param>
        public static void SetTextThreadSafe(this TextBox txtTarget,
                                             string strValue)
        {
            BaseTools.SetPropertyValue(txtTarget, "Text", strValue);
        }

        /// <summary>
        /// Allows thread-safe manipulation of the MultiLine-property.
        /// </summary>
        /// <param name="txtTarget">The <c>System.Windows.Forms.TextBox</c>-control.</param>
        /// <param name="blnValue">A boolean value for the MultiLine-property.</param>
        public static void SetMultiLineThreadSafe(this TextBox txtTarget,
                                                  bool blnValue)
        {
            BaseTools.SetPropertyValue(txtTarget, "MultiLine", blnValue);
        }

        /// <summary>
        /// Allows thread-safe manipulation of the MexLength-property.
        /// </summary>
        /// <param name="txtTarget">The <c>System.Windows.Forms.TextBox</c>-control.</param>
        /// <param name="intValue">The maximum amount of chars the control will accept.</param>
        public static void SetMaxLengthThreadSafe(this TextBox txtTarget,
                                                  int intValue)
        {
            BaseTools.SetPropertyValue(txtTarget, "MaxLength", intValue);
        }

    }
}
